
Ext.define("entgpv11.view.details.UsgsMapGeneric", {
    extend: 'Ext.Map',
    alias: "widget.usgsmapgeneric",
    config: {

        //useCurrentLocation: true,
        mapOptions: {
            zoom: 12 //0-18
        },
        listeners: [
            {
                fn: 'onMapMaprender'
                //,event: 'maprender'
            }
        ]
        //,mgr :null
        //,dataLatLng: null
    },
    onMapMaprender: function (map, gmap, options) {
        /*
        var data = this.getDataLatLng();
        var neighborhoods = [
        //new google.maps.LatLng(Ext.Number.toFixed(data.Latitud,6),Ext.Number.toFixed(data.Longitud,6))
        ];
        for (var i = 0; i < neighborhoods.length; i++) {
        var m = neighborhoods[i];

        new google.maps.Marker({
        position: m,
        map: gmap,
        draggable: false,
        animation: google.maps.Animation.DROP
        });
        }
        */
        //this.setMgr(new MarkerManager(map));
        //gmap("removeAllMarkers");

        //marker.setMap(null);
        //console.log("onMapMaprender");


    },
    addMarker: function (record) {
        try {
             //google.maps.Map.prototype.clearMarkers();
            var data = record.data;
            var numberFixed = {
                'lat': Ext.Number.toFixed(data.Latitud, 6),
                'lng': Ext.Number.toFixed(data.Longitud, 6)
            };
            /*
            if (!this.markerExists(numberFixed.lat, numberFixed.lng)) { // custom method 
		 
            // cache the newest point so we don't add it in the future
            this.markerCache.add({
            lat: numberFixed.lat,
            lng: numberFixed.lng});
            }*/
            var infoWindow = null;
           
            /*
            try
            {
                infoWindow = new google.maps.InfoWindow();
            }
            catch(ex)
            {
                var script = document.createElement("script");
                var head   = document.getElementsByTagName('head').item(0);
                script.type = "text/javascript";
                script.src = APP_GLOBAL.getGoogleURL();
                head.appendChild(script);
			
            }
            */
            var point = new google.maps.LatLng(numberFixed.lat, numberFixed.lng);

            var marker = new google.maps.Marker({
                map: this.getMap(),
                position: point
            });
            infoWindow = new google.maps.InfoWindow();
            this.getMap().setCenter(point); // Center your map
            //this.getMgr().addMarker(marker);
            //this.getMgr().refresh();


            google.maps.event.addListener(marker, "click", function () {
                var desc = '<div class=\'usgsMapInfoWindow\'>' + data.Nombre + '<br/>' + data.Descripcion + '</div>';

                infoWindow.setContent(desc);
                infoWindow.open(this.getMap(), marker);
            });
        }
        catch (ex) {
            APP_GLOBAL.SetLog(ex);
        }
    }
});

